// src/api/articles.js
import request from '@/utils/request'

// 获取文章列表
export function getArticleList() {
  return request({
    url: '/articles/getArticleList',
    method: 'get',
  })
}
// 添加文章
export function addArticle(data) {
  return request({
    url: '/articles/addArticle',
    method: 'post',
    data,
  })
}
// 获取文章内容
export function getArticleContent(id) {
  return request({
    url: `/articles/getArticleContent/${id}`,
    method: 'get',
  })
}

// 上传图片
export function uploadImage(file) {
  const formData = new FormData()
  formData.append('image', file)
  return request({
    url: '/articles/uploadImage',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data',
    },
  })
}